package com.yan.demo;

import java.math.BigDecimal;

public class Demo8 {
    public static void main(String[] args) {
        BigDecimal big1 = new BigDecimal("23.24456789");
        System.out.println("原数字:" + big1);
        Handleable quZeng = new Handleable() {
            @Override
            public String handleString(String num) {
                BigDecimal big = new BigDecimal(num);
                BigDecimal divide = big.divide(new BigDecimal("1"), 0, BigDecimal.ROUND_DOWN);
                return divide.toString();
            }
        };
        String s = quZeng.handleString(big1.toString());
        System.out.println("取整后: " + s);

        Handleable roundItUp = num -> new BigDecimal(num).divide(new BigDecimal("1"), 4 , 4).toString();

        String s1 = roundItUp.handleString("23.23456789");
        System.out.println("保留四位小数,四舍五入后的值为:" + s1);

    }
}
